package com.example.demo.common.utils.demo;

import com.alibaba.fastjson.JSONObject;
import com.example.demo.common.utils.BaseResponse;
import com.example.demo.common.utils.HttpUtil;
import com.example.demo.common.utils.RSAHelper;
import com.example.demo.common.utils.demo.common.Config;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * @author zhangws email:1127145966@qq.com
 * @Description: 代付结果查询demo
 * @Date:2019/7/22 0022 10:06
 */
public class PaymentResult {
    static Logger log = LoggerFactory.getLogger(PaymentResult.class);
    /**
     * 发放结果查询，一次性最多查询10个
     * thirdOrderIds
     */
    public static  void queryResult(List<String> thirdOrderIds){
        String url = Config.baseUrl+"/open/api/v1/bill/queryResult";
        String paramsJson = JSONObject.toJSONString(thirdOrderIds);
        BaseResponse baseResponse = HttpUtil.post(url,paramsJson,Config.appKey,Config.secretkey,Config.publicKey);
        String rs = baseResponse.getData().toString();
        //公钥解密
        if (StringUtils.isNotBlank(rs)){
            try {
                String dec = RSAHelper.decryptByPublicKey(rs,Config.publicKey);
                log.info("解密结果:{}",dec);
            }catch (Exception e){
                log.error("publicKey 有误");
            }
        }
    }
}
